<template>
	<view class="wanlshop-buyProcess-container" :style="{ '--bg': appStyle.home_nav_color }">
		<uv-tabs :current="current" :list="processData" lineColor="#fd8c00" :activeStyle="{
			color: '#333333',
		}" :inactiveStyle="{ color: '#333333' }" :itemStyle="{ width: '50%', height: '72rpx'}" :lineWidth="40" @click="changeCurrent"></uv-tabs>
		
		<view class="content" v-if="current == 0">
			<view class="step" v-for="(item, index) in buyProcess.pickup" :key="index">
				<view class="left">
					<view class="image">
						<image style="width: 100%; height: 100%" :src="$wanlshop.oss(item.icon)"></image>
					</view>
					<view class="line" v-if="(index + 1) < buyProcess.pickup.length"></view>
				</view>
				<view class="right">
					<view class="title">{{ item.title }}</view>
					<view class="desc">{{ item.desc }}</view>
				</view>
			</view>
		</view>
		
		<view class="content" v-if="current == 1">
			<view class="step" v-for="(item, index) in buyProcess.delivery" :key="index">
				<view class="left">
					<view class="image">
						<image style="width: 100%; height: 100%" :src="$wanlshop.oss(item.icon)"></image>
					</view>
					<view class="line" v-if="(index + 1) < buyProcess.delivery.length"></view>
				</view>
				<view class="right">
					<view class="title">{{ item.title }}</view>
					<view class="desc">{{ item.desc }}</view>
				</view>
			</view>
		</view>
	</view>	
</template>

<script>
	import {
		mapState,
		mapActions
	} from 'vuex';
	export default {
		data() {
			return {
				current: 0,
				// 购买流程
				buyProcess: {},
				processData: [
					{
						name: '购买流程'
					},
					{
						name: '配送到家'
					}
				]
			}
		},
		computed: {
			...mapState(['common']),
			// 全局样式
			appStyle() {
				let style = this.common.appStyle;
				uni.setNavigationBarColor({
					backgroundColor: style.home_nav_color
				});
				return style;
			}
		},
		onLoad(option) {
			//加载购买流程
			this.$api.get({
				url: '/wanlshop/buy_step/index',
				data: {
					category_id: option.category_id,
				},
				success: res => {
					this.buyProcess = res;
				}
			})
		},
		methods: {
			changeCurrent(e) {
				this.current = e.index;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wanlshop-buyProcess-container {
		background-color: var(--bg);
		width: 100%;
		min-height: 100vh;
		height: 100%;
		padding: 18rpx;
	}
	.content{
		background-color: #ffffff;
		border-radius: 16rpx;
		padding: 20rpx;
		.step {
			display: flex;
			position: relative;
			.left {
				//width: 42rpx;
				//overflow: hidden;
				.image {
					width: 46rpx;
					height: 46rpx;
				}
				.line {
					position: absolute;
					top: 24px;
					left: 9px;
					width: 1rpx;
					height: 61%;
					border-left: 1rpx dashed #fe8c00;
				}
			}
			.right {
				margin-left: 8rpx;
				padding-bottom: 36rpx;
				.title {
					color: #333333;
					font-size: 32rpx;
					margin-bottom: 12rpx;
				}
				.desc {
					color: #656565;
					font-size: 28rpx;
				}
			}
		}
		.step:last-child {
			.right {
				padding-bottom: 0rpx;
			}
		}
	}
</style>